<?php
/**
 * Created by PhpStorm.
 * User: guozhen
 * Date: 16/9/11
 * Time: 上午9:50
 */
namespace controllers;

class Command{
    public function dos($data){
       // 定时统计{ "cmd": "tick", "operate":"statistics_data_result" }
        //重新统计{ "cmd": "tick", "operate":"again_statistics_data_result", "param":{"now_day":"2016-9-11"} }
        //重新统计某天{ "cmd": "tick", "operate":"again_one_statistics_data_result", "param":{"now_day":"2016-9-10","name":"HOSPITAL","type":"1"} }
        $cmd = $data['cmd'];
        $operate = $data['operate'];
        $ret = ['status'=>'err','errcode'=>'','msg'=>''];

        switch ($cmd){
            case 'tick':
                if($operate=='statistics_data_result'){
                    $Mtimers = new \models\Timer\TimersModel();
                    $ret = $Mtimers->Timer();
                }elseif ($operate=='again_statistics_data_result'){
                    $MtimersUp = new \models\Timer\TimersUpModel();
                    $ret = $MtimersUp->TimerUpDay($data['param']['now_day']);
                }elseif ($operate=='again_one_statistics_data_result'){
                    $MtimersUp = new \models\Timer\TimersUpModel();
                    $ret = $MtimersUp->TimersUp($data['param']['now_day'],$data['param']['name'],$data['param']['type']);
                }
                break;
            default:
                break;
        }
        return json_encode($ret);
    }
}